#ifndef YALB_ABSTRACTTREEMODEL_H
#define YALB_ABSTRACTTREEMODEL_H

#include <QAbstractItemModel>
#include <QVector>

class yALB_AbstractTreeItem {
public:
    yALB_AbstractTreeItem(yALB_AbstractTreeItem *_parent);
    virtual ~yALB_AbstractTreeItem();

    int childCount() const;
    int row() const;
    yALB_AbstractTreeItem* child(int index) const;
    yALB_AbstractTreeItem* parent() const;
    void clearChildren();

protected:
    // \NOTE: Really need to be protected?
    yALB_AbstractTreeItem *parentItem;
    QVector<yALB_AbstractTreeItem*> children;
};

class yALB_AbstractTreeModel : public QAbstractItemModel
{
    Q_OBJECT
public:
    yALB_AbstractTreeModel(yALB_AbstractTreeItem *_rootItem, QObject *parent = 0);
    virtual ~yALB_AbstractTreeModel();

    QVariant data(const QModelIndex &index, int role) const = 0;
    QVariant headerData(int section, Qt::Orientation orientation,
                        int role = Qt::DisplayRole) const = 0;
    int columnCount(const QModelIndex &parent = QModelIndex()) const = 0;

    Qt::ItemFlags flags(const QModelIndex &index) const;
    int rowCount(const QModelIndex &parent = QModelIndex()) const;
    QModelIndex index(int row, int column,
                      const QModelIndex &parent = QModelIndex()) const;
    QModelIndex index(yALB_AbstractTreeItem *item, int column) const;
    QModelIndex parent(const QModelIndex &index) const;
    
protected:
    yALB_AbstractTreeItem *rootItem;
};

#endif // YALB_ABSTRACTTREEMODEL_H
